<?php
App::uses('AppModel', 'Model');
class Statics extends AppModel {

	public $name = 'Statics';
	public $useTable = 'statics';

	/**
	 * Get level category parent
	 * @param number $id
	 * @return number $cat_level
	 */
	public function getLevelCategoryParent($id = null){
		$query = array(
				'conditions' => array(
					'id' => $id,
					'cat_active' => 1
				),
				'fields' => 'cat_level,cat_has_child',
		);
		try{
			$cat_parent = $this->find('first', $query);
			return $cat_parent['Category']['cat_level'];

		} catch (Exception $e) {
			throw new NotFoundException(__('Invalid category'));
		}
	}

}